from zb.zb_api import *

def GetCoinNum(coinjson, ak, sk):
    zb = zb_api(ak, sk)
    coins = zb.query_account()
    #print(coins)
    myCoins = coins['result']['coins']
    for i in myCoins:
        num = (float)(i['available'])
        num2 = (float)(i['freez'])
        if num > 0 or num2 > 0:
            if (i['enName'].lower() in coinjson.keys()):
                coinjson[i['enName'].lower()] = coinjson[i['enName'].lower()] + num + num2
            else:
                coinjson[i['enName'].lower()] = num + num2

if __name__ == '__main__':
    access_key    = '6d6a9741-1ed9-41b9-984c-f0c0a34d0bdc'
    access_secret = '9bbdc6da-2788-49c2-ad86-75a8452ee82c'
    coinjson = json.loads('{}')
    GetCoinNum(coinjson, access_key, access_secret)

    print(coinjson)